package Year22_Month03.day08;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] arr = s.split(" ");
        //闰年
        int[] arr1 = {31,29,31,30,31,30,31,31,30,31,30,31};
        //非闰年
        int[] arr2 = {31,28,31,30,31,30,31,31,30,31,30,31};
        int resday = 0;
        if(Integer.valueOf(arr[0]) % 4 == 0 && Integer.valueOf(arr[0]) % 100 != 0){
            for (Integer i = 0; i < Integer.valueOf(arr[1]) - 1; i++) {
                resday += arr1[i];
            }
            resday += Integer.valueOf(arr[2]);
        }else{
            for (Integer i = 0; i < Integer.valueOf(arr[1]) - 1; i++) {
                resday += arr2[i];
            }
            resday += Integer.valueOf(arr[2]);
        }
        System.out.println(resday);
    }
}
